Port ostree-pull to GSConsole
authorColin Walters <walters@verbum.org>
Thu, 24 Jan 2013 20:22:16 +0000 (15:22 -0500)
committerColin Walters <walters@verbum.org>
Thu, 24 Jan 2013 20:22:16 +0000 (15:22 -0500)
As part of this, we need to ensure our streams are inherited across
the chain of child processes.

src/libgsystem
src/ostree/ostree-pull.c
src/ostree/ot-admin-builtin-install.c
src/ostree/ot-admin-builtin-prune.c
src/ostree/ot-admin-builtin-pull-deploy.c
src/ostree/ot-admin-builtin-upgrade.c

index 43a525fd40faf7dfd261bf3d7469f642a68fad68..87bf968f3470657e5a80d3f937b2142f9f6fb53b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 43a525fd40faf7dfd261bf3d7469f642a68fad68
+Subproject commit 87bf968f3470657e5a80d3f937b2142f9f6fb53b
index f7fbf370eab085dbf35905d6b464281577c9a2c2..ff123d584a3abbc655a6579a4a93c1c0283ff981 100644 (file)
@@ -118,7 +118,6 @@ typedef struct {
   GError      **async_error;
   gboolean      caught_error;
 
-  gboolean      stdout_is_tty;
   guint         last_padding;
 } OtPullData;
 
@@ -238,7 +237,8 @@ uri_fetch_update_status (gpointer user_data)
           diff--;
         }
     }
-  g_print ("%c8%s", 0x1B, status->str);
+
+  gs_console_begin_status_line (gs_console_get (), status->str, NULL, NULL);
 
   g_string_free (status, TRUE);
 
@@ -289,10 +289,14 @@ static gboolean
 run_mainloop_monitor_fetcher (OtPullData   *pull_data)
 {
   GSource *update_timeout = NULL;
+  GSConsole *console;
+
+  console = gs_console_get ();
 
-  if (pull_data->stdout_is_tty)
+  if (console)
     {
-      g_print ("%c7", 0x1B);
+      gs_console_begin_status_line (console, "", NULL, NULL);
+
       update_timeout = g_timeout_source_new_seconds (1);
       g_source_set_callback (update_timeout, uri_fetch_update_status, pull_data, NULL);
       g_source_attach (update_timeout, g_main_loop_get_context (pull_data->loop));
@@ -301,9 +305,9 @@ run_mainloop_monitor_fetcher (OtPullData   *pull_data)
   
   g_main_loop_run (pull_data->loop);
 
-  if (pull_data->stdout_is_tty)
+  if (console)
     {
-      g_print ("\n");
+      gs_console_end_status_line (console, NULL, NULL);
       g_source_destroy (update_timeout);
     }
 
@@ -1232,8 +1236,6 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
 
   start_time = g_get_monotonic_time ();
 
-  pull_data->stdout_is_tty = isatty (1);
-
   pull_data->remote_name = g_strdup (argv[1]);
   pull_data->fetcher = ostree_fetcher_new (ostree_repo_get_tmpdir (pull_data->repo));
   config = ostree_repo_get_config (repo);
index 23ff6ad49e738db7c2506fa73d6a68abcc68dfd1..06249a952a2d97ee44e2183b899ccad677442085 100644 (file)
@@ -134,7 +134,7 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
                                 NULL);
 
   if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                       cancellable, error,
                                       "ostree", "admin", ostree_dir_arg, "os-init", osname, NULL))
     goto out;
@@ -172,7 +172,7 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
       goto out;
     
     if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                        GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                        GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                         cancellable, error,
                                         "ostree", repoarg, "remote", "add",
                                         osname, repourl, tree_to_deploy, NULL))
@@ -180,13 +180,13 @@ ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
   }
 
   if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                       cancellable, error,
                                         "ostree", "pull", repoarg, osname, NULL))
     goto out;
 
   if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                       cancellable, error,
                                       "ostree", "admin", ostree_dir_arg, "deploy", osname,
                                       tree_to_deploy, NULL))
index f53229c5b8acb88f13f2e691b72fdd7d4ec1df6f..2a3c42f643bdc5f70f45f31710f3a5b5fea6b949 100644 (file)
@@ -171,7 +171,7 @@ ot_admin_builtin_prune (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, G
       repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL);
       
       if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                          GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                          GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                           cancellable, error,
                                           "ostree", repo_arg, "prune", "--refs-only",
                                           "--depth=0", NULL))
index 2fd3cd4ceba84a8dd73b59a2419c894738d6942d..6bfa4aa64b99775a81674757fe911c4582a82c14 100644 (file)
@@ -106,7 +106,7 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_o
                                            NULL);
 
     if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                        GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                        GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                         cancellable, error,
                                         "ostree", "pull", repo_arg, osname, NULL))
       goto out;
@@ -120,7 +120,7 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, OtAdminBuiltinOpts *admin_o
                                                      gs_file_get_path_cached (admin_opts->boot_dir),
                                                      NULL);
     if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                        GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                        GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                         cancellable, error,
                                         "ostree", "admin", opt_ostree_dir_arg, opt_boot_dir_arg, "deploy", osname,
                                         deploy_name, NULL))
index dc286574d629926065616940e1306db06b0962b8..f8ee8a0a89716a738e2012263190e293f9157d7e 100644 (file)
@@ -63,13 +63,13 @@ ot_admin_builtin_upgrade (int argc, char **argv, OtAdminBuiltinOpts *admin_opts,
                                 NULL);
 
   if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                       cancellable, error,
                                       "ostree", "admin", ostree_dir_arg, "pull-deploy", osname, NULL))
     goto out;
 
   if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir),
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_NULL,
+                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                       cancellable, error,
                                       "ostree", "admin", ostree_dir_arg, "prune", osname, NULL))
     goto out;